<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <img src="./../img/pug1.jpg" alt="" id="img">

    <script>
        let img = document.getElementById('img');
        let imgArr = ['pug1.jpg', 'pug2.jpg', 'pug3.jpg', 'pug4.jpg']
        let i = 0;
        setInterval(function () {
            i++;
            //当i大于数组的最后一个下标时，回到第一张重新轮博
            if (i > imgArr.length-1) {
                i = 0;
            }
            img.src = `./../img/${imgArr[i]}`;

        }, 1000)

    </script>

</body>

</html>